const Redis = require('ioredis')

const redis = new Redis({
  port: 6379,
  host: '182.92.122.236',
  password: 'root'
})

const redisConfig = {
  // redis存数据
  set:(key,value,time)=>{
    time ? redis.set(key, value, 'EX', time) : redis.set(key, value)
  },
  // redis获取数据
  get: (key) => {
    return redis.get(key)
  },
  // 删除数据
  del:  (key) => {
    return redis.del(key)
  },
  // 判断数据是否存在
  exists: (key) => {
    return redis.exists(key)
  },
}

module.exports = redisConfig